<template>
    <div>
        <div class="head">
            <span class="iconfont icon-arrow-left-bold" @click="gotoUp"></span>
            <div class="title">我的订单</div>
        </div>
        <div class="conter">
            <div class="item" v-for="item in arr" :key="item.id">
                <div class="title">
                    <div>{{ item.created_at | timeago }}</div>
                    <div>{{ item.status_text }}</div>
                </div>
                <div class="money">
                    <div>{{ item.goods[0].goods_name }}</div>
                    <div><span>￥</span>{{ item.goods[0].charge }}</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            arr: [],
        };
    },
    methods: {
        gotoUp() {
            this.$router.push({
                path: "/user",
                query: {},
            });
        },
    },
    async created() {
        let res = await this.$request.get("/api/v2/member/orders", {
            params: {
                page: 1,
                page_size: 10,
            },
        });
        this.arr = res.data.data;
    },
};
</script>

<style lang="less" scoped>
.head {
    position: fixed;
    top: 0;
    width: 100%;
    height: 50px;
    background-color: #fff;
    z-index: 100;
    padding-left: 15px;
    padding-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f2f6;
    span {
        font-size: 19px;
        position: absolute;
        top: 50%;
        margin-top: -10px;
        left: 4%;
    }
    .title {
        flex: 1;
        font-size: 17px;
        font-weight: 500;
        text-align: center;
        color: #333;
        line-height: 22px;
        overflow: hidden;
    }
}
.conter {
    padding-top: 50px;
    background: #f6f6f6;
    position: absolute;
    left: 0;
    top: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    .item {
        width: 100%;
        padding: 15px;
        background-color: #fff;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        .title {
            width: 100%;
            display: flex;
            padding-bottom: 15px;
            div:nth-child(1) {
                flex: 1;
                font-size: 10px;
                font-weight: 400;
                color: #999;
                line-height: 10px;
            }
            div:nth-child(2) {
                flex: 1;
                text-align: right;
                font-size: 13px;
                font-weight: 400;
                color: #999;
                line-height: 13px;
            }
        }
        .money {
            width: 100%;
            display: flex;
            div:nth-child(1) {
                flex: 1;
                font-size: 15px;
                font-weight: 400;
                color: #333;
                line-height: 15px;
                padding-bottom: 15px;
            }
            div:nth-child(2) {
                width: 120px;
                height: auto;
                text-align: right;
                font-size: 20px;
                font-weight: 400;
                color: #333;
                line-height: 20px;
                padding-top: 10px;
                span {
                    font-size: 10px;
                }
            }
        }
    }
}
</style>
